<script setup>
import { onMounted, reactive, ref, getCurrentInstance } from 'vue';
import { getImage } from '@/utils/global'
import sksqOption from './sksq'
import onePoi from '../onePoi.vue'

const sksqData = [
  {
    label: '官庄水库',
    sksw: 121.93,
    ssxsl: 95.58,
    sythkr: 25.42,
  },
  {
    label: '大京水库',
    sksw: 91.75,
    ssxsl: 9.97,
    sythkr: 3.31,
  },
  {
    label: '望仙桥水库',
    sksw: 134.95,
    ssxsl: 9.743,
    sythkr: 6.957,
  },
  {
    label: '雪峰山水库',
    sksw: 139.15,
    ssxsl: 9.997,
    sythkr: 2.403,
  },
  {
    label: '荷田水库',
    sksw: 95.98,
    ssxsl: 6.688,
    sythkr: 6.312,
  },
]

const dibaTable = [
  {
    name: '望仙桥水库',
    xbwy: 5.4,
    slylsw: '25.9',
    sj: '2024-07-29',
  },
  {
    name: '湘芸路至凿石港湘江大堤',
    xbwy: 6.9,
    slylsw: '25.9',
    sj: '2024-07-29',
  },
  {
    name: '王家洲大堤',
    xbwy: 2.1,
    slylsw: '25.9',
    sj: '2024-07-29',
  },
  {
    name: '凿石港至白沙洲两段大堤',
    xbwy: 5.1,
    slylsw: '25.9',
    sj: '2024-07-29',
  },
]

const chartData = reactive({
  sksqChartData: sksqOption(sksqData)
})



</script>

<template>
  <!-- <one-poi /> -->
  <div class="global-header-title">
    <img :src="getImage('home/waijiedata_icon.png')" alt="" />
    <span>水库水情</span>
  </div>
  <div class="sksq-div">
    <echarts-vue :chartData="chartData.sksqChartData" />
  </div>

  <div class="global-header-title">
    <img :src="getImage('home/waijiedata_icon.png')" alt="" />
    <span>堤坝工情</span>
  </div>
  <div class="dbgq-div">
    <div class="diba-div">
      <div class="item" v-for="item in dibaTable" :key="item.name">
        <div class="name">{{ item.name }}</div>
        <div class="info">
          <div>
            <div>位移(mm)</div>
            <div>{{ item.xbwy }}</div>
          </div>
          <div>
            <div>渗压(m)</div>
            <div :class="item.slylsw > 20 ? 'info-orange' : ''">
              {{ item.slylsw }}
            </div>
          </div>
          <div>
            <div>时间</div>
            <div>{{ type == 'default' ? curTime : item.sj }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div class="global-header-title">
    <img :src="getImage('home/zhuangtai_icon.png')" alt="" />
    <span>设备在线率</span>
  </div>
  <div class="sbzxl-div">
    <div class="name">北斗设备</div>
    <div class="cont">
      <div class="item">
        <div class="top">
          <div class="device-name">GNSS设备(52)</div>
          <div class="rate">100%</div>
        </div>

        <div class="device">
          <div class="device-item">
            <span>在线</span>
            <span>52</span>
          </div>
          <div class="device-item">
            <span>离线</span>
            <span>0</span>
          </div>
        </div>
      </div>
      <div class="item">
        <div class="top">
          <div class="device-name">手持巡检设备(12)</div>
          <div class="rate">100%</div>
        </div>
        <div class="device">
          <div class="device-item">
            <span>在线</span>
            <span>12</span>
          </div>
          <div class="device-item">
            <span>离线</span>
            <span>0</span>
          </div>
        </div>
      </div>
    </div>
    <div class="name">水文设备</div>
    <div class="cont">
      <div class="item">
        <div class="top">
          <div class="device-name">水文站(17)</div>
          <div class="rate">100%</div>
        </div>
        <div class="device">
          <div class="device-item">
            <span>在线</span>
            <span>17</span>
          </div>
          <div class="device-item">
            <span>离线</span>
            <span>0</span>
          </div>
        </div>
      </div>
      <div class="item">
        <div class="top">
          <div class="device-name">水位站(112)</div>
          <div class="rate">100%</div>
        </div>
        <div class="device">
          <div class="device-item">
            <span>在线</span>
            <span>112</span>
          </div>
          <div class="device-item">
            <span>离线</span>
            <span>0</span>
          </div>
        </div>
      </div>
      <div class="item">
        <div class="top">
          <div class="device-name">雨量站(231)</div>
          <div class="rate">100%</div>
        </div>
        <div class="device">
          <div class="device-item">
            <span>在线</span>
            <span>231</span>
          </div>
          <div class="device-item">
            <span>离线</span>
            <span>0</span>
          </div>
        </div>
      </div>
      <div class="item">
        <div class="top">
          <div class="device-name">视频站(58)</div>
          <div class="rate">100%</div>
        </div>
        <div class="device">
          <div class="device-item">
            <span>在线</span>
            <span>58</span>
          </div>
          <div class="device-item">
            <span>离线</span>
            <span>0</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="less" scoped>
.sksq-div {
  height: calc(40% - 40px);
}

.dbgq-div {
  height: calc(30% - 40px);

  .diba-div {
    height: 100%;
    overflow-y: auto;

    .item {
      margin-bottom: 10px;

      .name {
        padding-left: 20px;
        margin-bottom: 10px;
        font-family: MicrosoftYaHeiSemibold;
        font-size: 18px;
        color: #ffffff;
        font-style: normal;
        position: relative;

        &::before {
          content: '';
          display: inline-block;
          position: absolute;
          top: 8px;
          left: 0;
          width: 10px;
          height: 10px;
          border-radius: 50%;
          background: linear-gradient(180deg, #abffc4 0%, #09a428 100%);
        }
      }

      .info {
        display: flex;
        justify-content: space-between;
        padding: 0 15px;

        .info-orange {
          color: orange;
        }

        & > div {
          width: 100px;
          height: 60px;
          border-radius: 5px;
          background: url('@/assets/image/home/info-bg.png') no-repeat;
          background-size: 100% 100%;
          font-family: DINCond, DINCond;
          font-weight: 900;
          font-size: 16px;
          color: rgba(255, 255, 255, 1);
          text-align: center;
          font-style: normal;
          display: flex;
          flex-direction: column;
          justify-content: center;
        }
      }
    }
  }
}

.sbzxl-div {
  height: calc(30% - 40px);

  overflow-y: auto;

  .name {
    padding-left: 20px;
    margin-bottom: 10px;
    font-family: MicrosoftYaHeiSemibold;
    font-size: 16px;
    color: #ffffff;
    font-style: normal;
    position: relative;

    &::before {
      content: '';
      display: inline-block;
      position: absolute;
      top: 8px;
      left: 0;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: linear-gradient(180deg, #abffc4 0%, #09a428 100%);
    }
  }

  .cont {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;

    .item {
      width: 165px;
      height: 60px;
      background: url('@/assets/image/home/device.png') no-repeat;
      background-size: 100% 100%;
      text-align: center;
      margin-bottom: 10px;

      .top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 3px 5px 0;

        .device-name {
          font-family: MicrosoftYaHeiSemibold;
          font-size: 13px;
          color: #ffffff;
          font-style: normal;
          // margin-top: px;
        }

        .rate {
          font-family: DINAlternate, DINAlternate;
          font-weight: bold;
          font-size: 18px;
          color: #ffe026;
          font-style: normal;
          // margin-bottom: 14px
        }
      }

      .device {
        display: flex;
        // justify-content: space-around;

        .device-item {
          font-size: 14px;
          color: #ffffff;
          font-style: normal;
          padding-left: 20px;
          position: relative;

          span {
            vertical-align: middle;
          }

          &:nth-child(1)::before {
            content: '';
            display: inline-block;
            position: absolute;
            left: 10px;
            top: 8px;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: linear-gradient(180deg, #abffc4 0%, #09a428 100%);
          }

          &:nth-child(2)::before {
            content: '';
            display: inline-block;
            position: absolute;
            left: 10px;
            top: 8px;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: linear-gradient(180deg, #ffabab 0%, #e91212 100%);
          }

          &:nth-child(1) span:nth-child(2) {
            font-weight: bold;
            font-size: 16px;
            color: #24e16f;
            font-style: normal;
            margin-left: 6px;
          }

          &:nth-child(2) span:nth-child(2) {
            font-weight: bold;
            font-size: 16px;
            color: #ff4b3b;
            font-style: normal;
            margin-left: 6px;
          }
        }
      }
    }
  }
}
</style>